#!/bin/bash

# Test doing heavy IO while confchg change

. ./common

for i in `seq 0 15`; do
    _start_sheep $i
done

_wait_for_sheep 16

_cluster_format -c 3

for i in `seq 0 4`; do
    _vdi_create test$i 100M
done

for i in `seq 0 4`; do
    _random | $DOG vdi write test$i -p 7000 &
done

sleep 1

echo begin kill

_kill_sheep 1
_kill_sheep 2
_wait_for_sheep_recovery 0
_kill_sheep 3
_kill_sheep 4
_wait_for_sheep_recovery 0
_kill_sheep 5
_wait_for_sheep_recovery 0

for i in `seq 1 5`; do
    _start_sheep $i
done

echo wait for object recovery to finish
_wait_for_sheep_recovery 0
wait

for i in `seq 0 4`; do
    for port in `seq 0 7`; do
        $DOG vdi read test$i -p 700$port | md5sum > $STORE/csum.$port &
    done
    wait
    for port in `seq 1 7`; do
        diff -u $STORE/csum.0 $STORE/csum.$port
    done
done
